//
//  HDApiResult.swift
//  HuaDaoPeifu
//
//  Created by 刘杰 on 2018/7/4.
//  Copyright © 2018年 paiyipai. All rights reserved.
//

enum HDApiResultStatus:Int {
    case Failure=0,Success,Two,Three,Four,Five
}

enum HDpolicyStatus:Int {
    
    case Quest = -1
     ,NOStatus = 0
     ,PreAuditing = 1// 初审中
     ,PreAuditingSendBack = 2// 初审退回
     ,PreEnd = 3// 预结案
     ,PreEnd2 = 9// 预结案
     ,Ended = 4// 结案
     ,NeedFile = 5 //待补件
     ,Auditing = 6// 审核中
     ,Closed = 7// 关闭案件
     ,Appealling = 16 // 申诉中
     ,GiveUp = 18 // 主动放弃
}

import UIKit

/// 请求返回值 的 最外层
class HDApiResult: NSObject {
    var status:HDApiResultStatus!
    var data:AnyObject?
    var msg:String?
    
    func modelCustomTransform(FromDictionary dic:[String:AnyObject]) -> Bool {
        if let status = dic["status"],
            let rawvalue = try? status as! Int
            {
                self.status = HDApiResultStatus(rawValue: rawvalue)
        }else{
            self.status = .Failure
        }
        
        return true
    }
}


/// 注册成功 返回值
class HDAccountInfo : NSObject {
    var token:String?
    var name:String?
    var phone:String?
    var login_type:String?
    var user_type:String?
    var insuranceno:String?
    var ackout:String?
    var uid:String?
    var headimg:String?
    var tphone:String?
    var insuredgrade:String?
    var crittype_info:String?
    var crittype:String?
    var critcode:String?
}

// 积分详细数据
class HDIntegralDetail : NSObject {
    var id:String?
    var created:String?
    var updated:String?
    var status:String?
    var uid:String?
    var policyno:String?
    var upload_time:String?
    var firstimg_time:String?
    var is_dishonor:String?
    var closing_time:String?
    var payment_amount:String?
    var username:String?
    var insurance_name:String?
    var policyname:String?
    var insuredgrade:String?
    var loss_notice:String?
    var loss_notice_android:String?
    var hd_caseno:String?
    var insuredgroup:String?
    var policygroupremak:String?
    var sourceflag:String?
    var dishonor_introduce:String?
    var datatype:String?
    var last_upload_time:String?
    var fee:String?
    var insuredno:String?
    var area_code:String?
    var info_id:String?
    var product_name:String?
    var bdatatype:String?
    var introduce:String?
    var notice:String?
    var policyno1:String?
    var integral:String?
    
}

/// 用户银行信息
class HDUserBankInfo: NSObject {
    var bank:String?
    var bankcode:String?
}

/// 跟踪的保单数据集合
class HDFollowedPolicyListModel: NSObject {
    var num1:String?
    var num2:String?
    var num3:String?
    var num4:String?
    
    var part1:[HDPolicyModel]?
    var part2:[HDPolicyModel]?
    var part3:[HDPolicyModel]?
    var part4:[HDPolicyModel]?
    
    /*
     + (NSDictionary *)modelContainerPropertyGenericClass {
     return @{@"shadows" : [Shadow class],
     @"borders" : Border.class,
     @"attachments" : @"Attachment" };
     }
     */
    static func modelContainerPropertyGenericClass() -> [String:AnyObject]? {
        return [
            "part1":HDPolicyModel.self,
            "part2":HDPolicyModel.self,
            "part3":HDPolicyModel.self,
            "part4":HDPolicyModel.self
        ]
    }
}





/// 跟踪的保单数据
class HDPolicyModel: NSObject {
    var id:String = ""
    var policyno:String = ""
    var payment_amount:String = ""
    var is_dishonor:String = ""
    var upload_time:String = ""
    var closing_time:String = ""
    var ctime:String = ""
    /// 案件状态：  1:初审中  2:初审退回  3&9:预结案  4:已结案 6：审核中 5：待补件  7：关闭案件  16：申诉中 18：放弃案件
    var status:String = ""
    var policyStatus:HDpolicyStatus = HDpolicyStatus.NOStatus
    var STARTTIME:String = ""
    var ENDTIME:String = ""
    var product_name:String = ""
    var INSURANCE_NAME:String = ""
    var img:String = ""
    var created:String? = ""
    
    override var description: String{
        return self.yy_modelDescription()
    }
    
    static func statusImageName(status: HDpolicyStatus) -> String?{
        var imageName:String?
        if status == .PreAuditing {
            imageName = "初审中_icon"
        }else if status == .PreAuditingSendBack {
            imageName = "初审退回_icon"
        }else if status == .PreEnd || status == .PreEnd2 {
            imageName = "预结案_icon"
        }else if status == .Ended {
            imageName = "已结案_icon"
        }else if status == .NeedFile {
            imageName = "待补件_icon"
        }else if status == .Auditing {
            imageName = "审核中_icon"
        }else if status == .Closed {
            imageName = "关闭案件_icon"
        }else if status == .Appealling {
            imageName = "申诉中_icon"
        }else if status == .GiveUp {
            imageName = "放弃案件_icon"
        }
        return imageName
    }
    static func statusImageName(Status status:String)->String?{
        var imageName:String?
        if status == "1" {
            imageName = "初审中_icon"
        }else if status == "2" {
            imageName = "初审退回_icon"
        }else if status == "3" || status == "9" {
            imageName = "预结案_icon"
        }else if status == "4" {
            imageName = "已结案_icon"
        }else if status == "5" {
            imageName = "待补件_icon"
        }else if status == "6" {
            imageName = "审核中_icon"
        }else if status == "7" {
            imageName = "关闭案件_icon"
        }else if status == "16" {
            imageName = "申诉中_icon"
        }else if status == "18" {
            imageName = "放弃案件_icon"
        }
        return imageName
    }
    
    func modelCustomTransformFromDictionary(_ dic:[String:Any]) -> Bool {
        if let status = dic["status"] as? String{
            policyStatus = HDpolicyStatus(rawValue: Int(status) ?? 0)!
        }
        return true
    }
    
    /*
     - (BOOL)modelCustomTransformFromDictionary:(NSDictionary *)dic {
     NSNumber *timestamp = dic[@"timestamp"];
     if (![timestamp isKindOfClass:[NSNumber class]]) return NO;
     _createdAt = [NSDate dateWithTimeIntervalSince1970:timestamp.floatValue];
     return YES;
     }
     */
}
/// 保单操作历史数据
class HDPolicyLogModel: NSObject {
    var id:String = ""
    var title:String = ""
    var created:String = ""
    var updated:String = ""
    var case_id:String = ""
    var status:String = ""
    var policyStatus:HDpolicyStatus = .NOStatus
    var introduce:String = ""
    
    func modelCustomTransformFromDictionary(_ dic:[String:Any]) -> Bool {
        if let status = dic["status"] as? String{
            policyStatus = HDpolicyStatus(rawValue: Int(status) ?? 0)!
        }
        return true
    }
}
///保单申请记录
class HDAppealLogModel: NSObject {
    var id:String = ""
    var case_id:String = ""
    var type:String = ""
    var content:String = ""
    var result:String = ""
    var status:String = ""
    var created:String = ""
    var policyStatus:HDpolicyStatus = .NOStatus
    func modelCustomTransformFromDictionary(_ dic:[String:Any]) -> Bool {
        if let status = dic["status"] as? String{
            policyStatus = HDpolicyStatus(rawValue: Int(status) ?? 0)!
        }
        return true
    }
}

/// 保单账单信息
class HDPolicyBillModel: NSObject {
    var id:String = ""
    var created:String = ""
    var updated:String = ""
    var status:String = ""
    var uid:String = ""
    var policyno:String = ""
    var upload_time:String = ""
    var firstimg_time:String = ""
    var is_dishonor:String = ""
    var closing_time:String = ""
    var payment_amount:String = ""
    var username:String = ""
    var insurance_name:String = ""
    var policyname:String = ""
    var insuredgrade:String = ""
    var loss_notice:String = ""
    var loss_notice_android:String = ""
    var hd_caseno:String = ""
    var insuredgroup:String = ""
    var policygroupremak:String = ""
    var sourceflag:String = ""
    var dishonor_introduce:String = ""
    var datatype:String = ""
    var last_upload_time:String = ""
    var fee:String = ""
    var insuredno:String = ""
    var area_code:String = ""
    var info_id:String = ""
    var ID:String = ""
    var INSURANCE_NO:String = ""
    var ORGANITION_NO:String = ""
    var CASENO:String = ""
    var INSUREDNO:String = ""
    var DUTYTYPE:String = ""
    var TOTALAMNT:String = ""
    var SOCIALAMNT:String = ""
    var SELFPAYAMNT:String = ""
    var NONPAYAMNT:String = ""
    var OWNAMNT:String = ""
    var CANPAYAMNT:String = ""
    var Deductibleamnt:String = ""
    var PAYRATIO:String = ""
    var PAYAMNT:String = ""
    var PAYTYPE:String = ""
    var STATUS:String = ""
    
    var BILLTYPE:String = ""
    var BILLReceiptNo:String = ""
    var hospitalname:String = ""
    var billbegindate:String = ""
    var totalamnt:String = ""
    var deductreason:String = ""
    var deductamnt:String = ""
    var deductreasonremark:String = ""
    /*
     "id": "79769",
     "created": "1530947144",
     "updated": "1531013608",
     "status": "9",
     "uid": "22735",
     "policyno": "PWBH201844010000000012",
     "upload_time": "1531013530",
     "firstimg_time": "1531013529",
     "is_dishonor": "2",
     "closing_time": "0",
     "payment_amount": "0",
     "username": "史青",
     "insurance_name": "PICC广州分公司",
     "policyname": "唯品会(中国)有限公司",
     "insuredgrade": "0",
     "loss_notice": "https:\/\/app.cdghealth.com\/caseApp\/pdf\/99160615\/98301430299160615001001.pdf",
     "loss_notice_android": "https:\/\/app.cdghealth.com\/caseApp\/pdf\/99180708\/61301020299180708001001.pdf",
     "hd_caseno": "61301020299180708001001",
     "insuredgroup": "",
     "policygroupremak": "",
     "sourceflag": "0",
     "dishonor_introduce": "",
     "datatype": "",
     "last_upload_time": "1531013530",
     "fee": "0",
     "insuredno": "0",
     "area_code": "2",
     "info_id": "37",
     "ID": "76852",
     "INSURANCE_NO": "0061",
     "ORGANITION_NO": "02",
     "CASENO": "61301020299180708001001",
     "INSUREDNO": "61000023",
     "DUTYTYPE": "自费药",
     "TOTALAMNT": "11.2500",
     "SOCIALAMNT": "0.0000",
     "SELFPAYAMNT": "11.2500",
     "NONPAYAMNT": "0.0000",
     "OWNAMNT": "0.0000",
     "CANPAYAMNT": "11.2500",
     "Deductibleamnt": "0.0000",
     "PAYRATIO": "50%",
     "PAYAMNT": "5.6300",
     "PAYTYPE": "1",
     "STATUS": "1"*/
}

/// 首页广告数据模型
class HDHomeBannerModel: NSObject {
    var img:String = ""
    var title:String = ""
    var id:String = ""
}

/// 首页保单数据模型
class HDHomePolicyModel: HDPolicyModel {
    var insurance_no:String = ""
    var insuredidno:String = ""
    var policyname:String = ""
    var starttime:String = ""
    var endtime:String = ""
    var insurance_name:String = ""
    var organition_name:String = ""
    var datatype:String = ""
    var bdatatype:String = ""
    var telephone:String = ""
}
///手册数据模型
class HDManualModel: NSObject {
    var title:String = ""
    var id:String = ""
    var policyno:String = ""
}
// 声明数据
class HDAnnouncementModel: NSObject {
    var id:String = ""
    var title:String = ""
    var policyno:String = ""
}
/// 被保人
class HDRecognizeeModel: NSObject {
    var id = ""
    var uid = ""
    var pid = ""
    var relation = ""
    var created = ""
    var partone:HDRecognizeeDetailModel?
    var parttwo:HDParttwoModel?
    var is_del = ""
    var identify = 0
    var status:String = ""
    var info_id = ""
    
    override var description: String{
        return yy_modelDescription()
    }
}

/// 被保人
class HDRecognizeeDetailModel: NSObject {
    var name = ""
    var sex = ""
    var critcode = ""
    var phone = ""
    var job = ""
    var address = ""
    var email = ""
    var account_name = ""
    var accountno = ""
    var reaccountno = ""
    var bank = ""
    var province = ""
    var city = ""
    var subBranch = ""
    var crittype = ""
    var images = ""
    var born_id = ""
    var re_page = ""
    
    override var description: String{
        return yy_modelDescription()
    }
}

class HDParttwoModel: NSObject {
    var claim_type = ""
    var claim_time = ""
    var hospital = ""
    var disease = ""
    var total_money = ""
    var claim_address = ""
    var accident_process = ""
    
    override var description: String{
        return yy_modelDescription()
    }
}

/// 本人被保人基本信息
class HDOrzinfoModel: NSObject {
    var name = ""
    var uid = ""
    var crittype = ""
    var critcode = ""
    var user_type = ""
    var phone = ""
    override var description: String{
        return yy_modelDescription()
    }
}
/// 图片上传返回值
class HDUploadImageResponse: NSObject {
    var imgurl = ""
    var created = ""
}
/// 案件初始化返回值
class HDCaseModel: NSObject {
    /// 所有附件类型
    // var datatype_list : [String:Any]?
    /// 附件中的必填项
    var bdatatype_list : String?
    /// 附件图片地址
    var datatypeimg : [String:String?]?
    /// 所有附件类型
    var datatype : String?
    /// 案件id
    var case_id = ""
    /// 金额上限
    var maxfee:Int = 0
    override var description: String{
        return yy_modelDescription()
    }
}

//保单图片资源返回值
class HDImagesModel: NSObject {
    override var description: String{
        return yy_modelDescription()
    }
}
/// 电子申请表模型
class HDApplicationFormModel: NSObject {
    var born_id = ""
    var city = ""
    var email = ""
    var name = ""
    var accountno = ""
    var address = ""
    var province = ""
    var critcode = ""
    var crittype = ""
    var re_page = ""
    var job = ""
    var phone = ""
    var bank = ""
    var images = ""
    var subBranch = ""
    var account_name = ""
    var sex = ""
    var identify = ""
//    var self = ""
    var relation = ""
    var claim_type = ""
    var claim_time = ""
    var hospital = ""
    var disease = ""
    var total_money = ""
    var claim_address = ""
    var accident_process = ""
    var created = ""
    
    override var description: String{
        return yy_modelDescription()
    }
}
